package cn.wolfcode.trip.base.domain;

import cn.wolfcode.trip.base.util.JSONUtil;
import lombok.Getter;
import lombok.Setter;

import java.util.HashMap;
import java.util.Map;

@Getter
@Setter
public class Region extends BaseDomain {

    public static final int STATE_NOMAL=0;
    public static final int STATE_HOT=1;

    private String name;

    private Region parent;

    private int state;


    public Map toTreeViewMap() {
        Map<Object, Object> maps = new HashMap<>();
     maps.put("text",name);
     maps.put("id",id);
     maps.put("lazyLoad",true);
     if(state==STATE_HOT){
         maps.put("tags",new String[]{"推荐"});
     }
     return maps;
    }

    public String getJson(){
        Map<String,Object> map=new HashMap<>();
        map.put("id", id);
        map.put("name", name);
        map.put("state",state);
        if(parent!=null){
        map.put("parentId",parent.getId());
        map.put("parentName",parent.getName());

        }
        return JSONUtil.toJSONString(map);
    }
}